# Makefile for image_demo

BINARY_NAME=image_demo
GO=go
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOTEST=$(GO) test
GOGET=$(GO) get

.PHONY: all build clean test run install-deps

all: build

build:
	@echo "Building $(BINARY_NAME)..."
	$(GOBUILD) -o $(BINARY_NAME) ./cmd

clean:
	@echo "Cleaning..."
	$(GOCLEAN)
	rm -f $(BINARY_NAME)
	rm -rf images

test:
	@echo "Running tests..."
	$(GOTEST) -v ./...

run: build
	@echo "Running $(BINARY_NAME)..."
	./$(BINARY_NAME)

install-deps:
	@echo "Installing dependencies..."
	$(GOGET) github.com/chai2010/webp

# Cross-compilation targets
build-linux:
	GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME)-linux ./cmd

build-windows:
	GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME).exe ./cmd

build-mac:
	GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME)-mac ./cmd

# Install to system (requires sudo)
install: build
	sudo cp $(BINARY_NAME) /usr/local/bin/

# Show help
help:
	@echo "Available targets:"
	@echo "  build         - Build the binary"
	@echo "  clean         - Remove built binaries and clean up"
	@echo "  test          - Run tests"
	@echo "  run           - Build and run the program"
	@echo "  install-deps  - Install dependencies"
	@echo "  build-linux   - Build for Linux"
	@echo "  build-windows - Build for Windows"
	@echo "  build-mac     - Build for macOS"
	@echo "  install       - Install to system"
	@echo "  help          - Show this help"
